<template>
  <div>
      <h1>详情页</h1>
      <p>{{w.id}}</p>
      <p>{{w.title}}</p>
      <p>{{w.content}}</p>
      <p>{{w.cate}}</p>
      <p>{{w.stars}}
          <input type="button" value="点赞" @click="stars">
      </p>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            id:this.$route.query.id,
            w:{}
        }
    },
    created() {
        axios.get('/api/login?id='+this.id).then(resp=>{
            console.log(resp)
            this.w = resp.data
        }).catch(error=>{
            console.log(error)
        })
    },
    methods: {
        stars(){
            axios.put('/api/login',{'id':this.id}).then(resp=>{
                console.log(resp.data)
                this.$route.go(0)
            }).catch(error=>{
                console.log(error)
            })
        }
    },
}
</script>

<style>

</style>